package com.dream.style.app.ac.acc;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.dream.style.R;
import com.dream.style.app.ac.help.ViewHelper;
import com.dream.style.app.ac.main.KztActivity;

/**
 * @Created by lincyu
 * @Time: 2018/11/13 11:17
 * @Decs: 类
 */
public class RegisterActivity extends Activity {

    private TextView yzm;
    private EditText etPsw;
    private boolean canSee = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_register);

        initEvent();
    }

    private void initEvent() {
        // 验证码
        yzm = findViewById(R.id.tv_get_yzm);
        yzm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegisterActivity.this,
                        "正在获取验证码", Toast.LENGTH_SHORT).show();
                // 第一步，进行倒计时动画
                ViewHelper.startDownTime(yzm,5000,1000);
                // 发送请求

            }


        });

        // 密码
        etPsw = findViewById(R.id.et_psw);
        ViewHelper.seePsw(this,etPsw);
//        etPsw.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View view, MotionEvent event) {
//                //如果不是按下事件，不再处理
//                if (event.getAction() != MotionEvent.ACTION_UP) {
//                    return false;
//                }
//                //如果右边没有图片，不再处理
//                if (etPsw.getCompoundDrawables()[2] == null){
//                    return false;
//                }
//                canSee = ViewHelper.seePsw(RegisterActivity.this,etPsw,canSee,event);
//                return false;
//            }
//        });

        // 注册
        findViewById(R.id.btn_register).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegisterActivity.this, "注册成功",
                        Toast.LENGTH_SHORT).show();
                start(KztActivity.class);
            }
        });
    }


    private void start(Class s) {
        Intent i = new Intent(this, s);
        startActivity(i);
        finish();
    }

}
